<?php
namespace Wxpay\Controller;
use Think\Controller;
vendor('Wxpay.lib.WxPay#Api');

class IndexController extends Controller {
        /**--支付主页--**/
    public function index()
    {
//        $wxpay = M('wxpay');
//        $data = '{"appid":"wx060aa1d7e0f584b8","attach":[],"bank_type":"CMB_CREDIT","cash_fee":"1","fee_type":"CNY","is_subscribe":"Y","mch_id":"1290532001","nonce_str":"Kmw10GVBWK4aZ1ZD","openid":"oQwmVxJ7RmwmUVgKK8jUjkOzjoMM","out_trade_no":"129053200120160219103704","result_code":"SUCCESS","return_code":"SUCCESS","return_msg":"OK","sign":"DF1A3DCF57BFC5A6C175D4564E51803B","time_end":"20160219103708","total_fee":"1","trade_state":"SUCCESS","trade_type":"MICROPAY","transaction_id":"1007830618201602193375378304"}';
//        $fp = fopen(DOC_ROOT.'/Public/data/wxpay.txt', 'r');
//        $data = fread($fp, filesize(DOC_ROOT.'/Public/data/wxpay.txt'));
//        fclose($fp);
//        $result = json_decode($data, true);
//        foreach ($result as $v) {
//            $wxpay->data($v)->add();
//        }

//        $data = $mxpay->select();
//        $fp = fopen(DOC_ROOT.'/Public/data/wxpay.txt', 'a');
//        fwrite($fp,json_encode($data));
//        fclose($fp);
        $this->display();
    }

    public function test(){
        $queryOrderInput = new \WxPayOrderQuery();
        $queryOrderInput->SetOut_trade_no('1111');
        $result = \WxPayApi::orderQuery($queryOrderInput);
        R('Common/Printf_info',array($result));
    }
}